from orm_learning.advanced_orm_learning.model.database import Database
from service.user_service import UserService


def main():
    mysql_connection_string = 'mysql+mysqlconnector://root:admin@localhost:3306/orm_coding'
    db = Database(mysql_connection_string)
    db.create_tables()

    session = db.Session()

    user_service = UserService(session)
    user_service.add_user_with_permissions('1111', 'password123', ['test'])

    users = user_service.get_users_with_permissions()
    for user in users:
        print(f"User: {user.username}, Permissions: {[p.name for p in user.permissions]}")


if __name__ == "__main__":
    main()
